import * as events from './events'

const mutations = {
  // [events.TEST_EVENT]: function (state, data) {
  //   state.test = data
  // },
  [events.SET_SERVICE_INFO]: function (state, data) {
    window.sessionStorage.setItem('serviceInfo', JSON.stringify(data))
    state.serviceInfo = data
  },
  [events.SET_CAT_NAME]: function (state, data) {
    window.localStorage.setItem('catName', JSON.stringify(data))
    state.catName = data
  },
  [events.SET_SHARE_DATA]: function (state, data) {
    state.voted = true
    state.shareData = data
  },
  [events.SET_CATE_STATUS]: function (state, data) {
    window.sessionStorage.setItem('categoryStatus', JSON.stringify(data))
    state.categoryStatus = data
  },
  [events.SET_PAGE_SWITCH]: function (state, data) {
    state.pageSwitch = data
  },
  [events.SET_CAT_ID]: function (state, data) {
    state.catid = data
  },
  [events.SET_DOWNLOAD_LINK]: function (state, data) {
    if (data) {
      window.sessionStorage.setItem('appDownloadLink', data)
      state.appDownloadLink = data
    }
  },
  [events.SET_WX_VOTE_LINK]: function (state, data) {
    if (data) {
      window.sessionStorage.setItem('wxVoteLink', data)
      state.wxVoteLink = data
    }
  },
  [events.SET_QRCODE_LIST]: function (state, data) {
    if (data) {
      window.sessionStorage.setItem('qrcodeList', JSON.stringify(data))
      state.qrcodeList = data
    }
  },
  [events.SET_WX_APPLET_LINK]: function (state, data) {
    if (data) {
      window.sessionStorage.setItem('wxAppletLink', data)
      state.wxAppletLink = data
    }
  },
  [events.SET_PC_VOTE_LINK]: function (state, data) {
    if (data) {
      window.sessionStorage.setItem('voteLink', data)
      state.voteLink = data
    }
  },
  [events.SET_GUIDE_LINK]: function (state, data) {
    if (data) {
      window.sessionStorage.setItem('guideShareLink', data)
      state.guideShareLink = data
    }
  },
  [events.SET_ERROR_WX_QRCODE]: function (state, data) {
    if (data) {
      window.sessionStorage.setItem('errorWxQrcode', data)
      state.errorWxQrcode = data
    }
  },
  [events.SET_ERROR_QQ]: function (state, data) {
    if (data) {
      window.sessionStorage.setItem('errorQQ', data)
      state.errorQQ = data
    }
  },
  [events.SET_WX_XCX_LINK]: function (state, data) {
    if (data) {
      window.sessionStorage.setItem('xcxLink', data)
      state.xcxLink = data
    }
  }
}
export default mutations